<!DOCTYPE html>
<html lang="en" xmlns:th="https://www.thymeleaf.org/">
<head th:replace="_fragment_front :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>归档</title>
    <link rel="stylesheet" href="../static/css/me.css">
    <link rel="stylesheet" href="../static/lib/semantic/semantic.min.css">
</head>
<body class="archiveBody body">

    <!--导航-->
    <nav th:replace="_fragment_front :: nav(5)" class="gird-header">
        <div class="ui container">
            <div class="ui inverted secondary stackable menu">
                <a href="#"><h2 class="ui olive header item">风铃</h2></a>
                <a href="#" class="m-item item m-mobile-hide"><i class="home icon"></i>首页</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="pencil alternate icon"></i>友链</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="graduation cap icon"></i>资源库</a>
                <a href="#" class="m-item item m-mobile-hide"><i class="clone icon"></i>归档</a>
                <div class="m-item item right m-mobile-hide">
                    <form action="#" name="search" target="_blank">
                        <div class="ui icon inverted transparent input m-margin-tb-tiny">
                            <input type="text" name="query" placeholder="Search....">
                            <i class="search link icon"></i>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
            <i class="sidebar icon"></i>
        </a>
    </nav>

    <!--顶部图片-->
    <div class="m-bg-type_outer m-top">
        <img th:src="@{/images/archive.jpg}" alt="分类背景图" class="ui m-bg image m-top-image">
        <div class="m-bg-class_cover">
            <div class="ui container m-top-image-text">
                <div class="m-font-size-title m-right-bottom m-center">归档</div>
                <div class="m-font-size-text-init-title m-margin-top m-center" th:text="#{archive-sentence}"></div>
            </div>
        </div>
    </div>

    <!-- 中间内容 -->
    <div id="waypoint" class="m-container-mini m-padded-tb-big">
        <div class="ui container">
            <div class="ui stackable grid">
                <!-- TODO 左边列表，需要修改 -->
                <div class="four wide column">

                    <!--人物-->
                    <div class="ui segments m-opacity">
                        <div class="ui segment">
                            <div class="m-margin-top" align="center">
                                <img th:src="@{/images/avatar.jpg}" alt="" class="ui circular image m-archive-avatar">
                            </div>
                            <div class="m-center m-text-medium" th:text="#{AdminName}">WindChime</div>
                            <div class="ui divider"></div>
                            <div class="extra content">
                                <div class="ui container">
                                    <div class="ui grid m-center m-padded-tb-small">
                                        <a href="#" class="ui wechat circular icon button m-margin-left-tiny"><i class="weixin icon"></i></a>
                                        <a href="#" class="ui QQ circular icon button m-margin-left-tiny"><i class="qq icon"></i></a>
                                        <a href="#" target="_blank" class="ui github circular icon button m-margin-left-tiny" data-content="点击跳转GitHub" data-position="bottom center"><i class="github icon"></i></a>
                                        <a href="#" class="ui email circular icon button m-margin-left-tiny" data-content="2540487435@qq.com" data-position="bottom center"><i class="envelope icon"></i></a>
                                    </div>
                                </div>

                                <div class="ui wechat-qr flowing popup m-margin-left-tiny transition hidden">
                                    <img th:src="@{/images/wechat.png}" alt="" class="ui rounded image m-QR">
                                    <div class="m-center">微信</div>
                                </div>

                                <div class="ui qq-qr flowing popup m-margin-left-tiny transition hidden">
                                    <img th:src="@{/images/QQ.jpeg}" alt="" class="ui rounded image m-QR">
                                    <div class="m-center">QQ</div>
                                </div>

                            </div>
                        </div>
                    </div>

                    <!--TODO 后续需要什么加什么-->

                </div>

                <!-- 右边列表-->
                <div class="twelve wide column m-opacity">
                    <!-- content -->
                    <div class="ui segment">

                        <h1>总览</h1>
                        <div class="ui three column stackable grid">
                            <div class="column">
                                <div class="ui segment m-blue-bg">
                                    <div class="ui grid">
                                        <div class="wide column m-center">
                                            <h1 class="m-white" th:text="${blogNum}">520</h1>
                                            <div class="m-text-medium m-white m-opacity-tiny">文章</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="column">
                                <div class="ui segment m-green-bg">
                                    <div class="ui grid">
                                        <div class="wide column m-center">
                                            <h1 class="m-white" th:text="${typeNum}">13</h1>
                                            <div class="m-text-medium m-white m-opacity-tiny">分类</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="column">
                                <div class="ui segment m-orange-bg">
                                    <div class="ui grid">
                                        <div class="wide column m-center">
                                            <h1 class="m-white" th:text="${tagNum}">14</h1>
                                            <div class="m-text-medium m-white m-opacity-tiny">标签</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <h1>统计</h1>
                        <div class="ui grid m-margin-top">
                            <div id="type" style="width: 100%; height: 288px;"></div>
                        </div>
                        <div class="ui grid m-margin-top">
                            <div id="tag" style="width: 100%; height: 288px;"></div>
                        </div>

                        <th:block th:each="archive : ${archives}">
                        <h2 class="ui center aligned header" th:text="${archive.key}">2021</h2>
                        <div class="ui fluid vertical menu">
                            <a th:href="@{/blog/{id}(id=${blog.id})}" target="_blank" class="item" th:each="blog : ${archive.value}">
                                <span>
                                    <i class="teal circle icon"></i><span th:text="${blog.title}">关于刻意练习的清单</span>
                                    <div class="ui teal basic left pointing label mini" th:text="${#dates.format(blog.createTime, 'MMMdd')}"><span>06月20</span></div>
                                </span>
                                <div class="ui basic label" th:classappend="${blog.flag ? 'green' : 'orange'}" th:text="${blog.flag ? '原创' : '转载'}">原创</div>
                            </a>
                        </div>
                        </th:block>

                    </div>
                </div>

            </div>
        </div>
    </div>

    <!--置顶图标-->
    <div id="toolbar" class="m-padded-tb-large m-fixed m-right-bottom" style="display: none">
        <a href="#" class="ui teal icon button"><i class="chevron up icon"></i></a>
    </div>

    <br>
    <br>

    <!--底部栏-->
    <footer th:replace="_fragment_front :: footer" class="ui inverted vertical segment m-padded-tb-massive m-opacity">
        <!--容器-->
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid">
                <div class="four wide column">
                    <div class="ui inverted m-text-thin m-text-spaced m-margin-top-max m-footer-title">联系我</div>
                    <div class="ui inverted link list">
                        <div class="m-text-thin">Email：2540487435@qq.com</div>
                        <div class="m-text-thin">QQ：2540487435</div>
                    </div>
                </div>

                <div class="four wide column" >
                    <div class="ui inverted link list">
                        <div class="item">
                            <!--微信二维码-->
                            <div class="ui inverted m-text-thin m-text-spaced m-footer-title">添加微信</div>
                            <img src="../static/images/wechat.png" class="ui m-margin-top rounded image m-QR" alt="">
                        </div>
                    </div>
                </div>

                <div class="four wide column">
                    <div class="ui inverted link list">
                        <div class="item">
                            <!--qq群二维码-->
                            <div class="ui inverted m-text-thin m-text-spaced m-footer-title">添加QQ</div>
                            <img src="../static/images/QQ.jpeg" class="ui m-margin-top rounded image m-QR" alt="">
                        </div>
                    </div>
                </div>
                <!--博客运行时间统计-->
                <div class="four wide column">
                    <div style="font-size: large;font-weight: bold" class="ui inverted m-text-thin m-text-spaced m-margin-top">博客总览</div>
                    <div id="blog-message">
                        <div class="ui inverted link list m-padded-tiny m-margin-top">
                            <div class="m-text-thin m-footer-position">
                                文章总数： <h4 class="ui orange header m-inline-block m-margin-top-null"> 1314 </h4> 篇
                            </div>
                            <div class="m-text-thin m-footer-position">
                                访问总数： <h4 class="ui orange header m-inline-block m-margin-top-null"> 1314 </h4> 次
                            </div>
                            <div class="m-text-thin m-footer-position">
                                评论总数： <h4 class="ui orange header m-inline-block m-margin-top-null"> 1314 </h4> 条
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="ui inverted section divider"></div>
            <div class="ui inverted m-text-thin m-text-spaced m-footer-time">此网站已运行：<span id="timer" class="item m-text-thin"></span></div>
        </div>
    </footer>

    <!--/*/<th:block th:replace="_fragment_front :: script">/*/-->
    <script src="../static/layuimini/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script src="../static/lib/semantic/semantic.min.js"></script>
    <script src="../static/lib/waypoints/jquery.waypoints.min.js"></script>
    <!--人物的看板娘-->
    <script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script>

    <script>
        /*此处为网站的创建时间*/
        function setTime() {
            var create_time = Math.round(new Date(Date.UTC(2021, 6, 23, 0, 0, 0)).getTime() / 1000);
            var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
            currentTime = secondToDate((timestamp - create_time));
            $('#timer').html(currentTime[0] + '年' + currentTime[1] + '天' + currentTime[2] + '时' + currentTime[3] + '分' + currentTime[4] + '秒')
        }
        setInterval(setTime, 1000)
        //计算时间
        function secondToDate(second) {
            if (!second) {
                return 0
            }
            var time = new Array(0, 0, 0, 0, 0)
            if (second >= 365 * 24 * 3600) {
                time[0] = parseInt(second / (365 * 24 * 3600))
                second %= 365 * 24 * 3600
            }
            if (second >= 24 * 3600) {
                time[1] = parseInt(second / (24 * 3600))
                second %= 24 * 3600
            }
            if (second >= 3600) {
                time[2] = parseInt(second / 3600)
                second %= 3600
            }
            if (second >= 60) {
                time[3] = parseInt(second / 60)
                second %= 60
            }
            if (second > 0) {
                time[4] = second
            }
            return time;
        }

        //看板娘初始化
        L2Dwidget.init({
            "model": {
                jsonPath: "https://unpkg.com/live2d-widget-model-miku@1.0.5/assets/miku.model.json",
                "scale": 1
            },
            "display": {
                "position": "left",
                "width": 120,
                "height": 170,
                "hOffset": 0,
                "vOffset": 0
            },
            "mobile": {
                "show": true,
                "scale": 0.5
            },
            "react": {
                "opacityDefault": 0.7,
                "opacityOnHover": 0.8
            },
        })

        //回到顶部按钮
        var waypoint = new Waypoint({
            element: $('#waypoint'),
            handler: function(direction) {
                if (direction == 'down') {
                    $('#toolbar').show(100)
                } else {
                    $('#toolbar').hide(500)
                }
            }
        })

        //手机汉堡菜单
        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('m-mobile-hide');
        })

    </script>
    <!--/*/</th:block>/*/-->

<script th:src="@{/layuimini/js/lay-module/echarts/echarts.js}"></script>

    <script>

        //获取ID对象
        var typeChart = echarts.init(document.getElementById('type'))
        var tagChart = echarts.init(document.getElementById('tag'))

        //分类图表方法
        function typeChartMethod() {
            // 指定图表的配置项和数据
            $.ajax({
                type: 'POST',
                url: '/getBars',
                success: function (res) {
                    var typeOption = {
                        title: {
                            text: '文章发布统计图',
                            textStyle : {
                                fontWeight: 'normal'
                            },
                            left: 'center'
                        },
                        tooltip: {
                            trigger: 'axis'
                        },
                        xAxis: {
                            data: res.names
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [{
                            data: res.values,
                            type: 'bar'
                        }]
                    }
                    // 使用刚指定的配置项和数据显示图表。
                    typeChart.setOption(typeOption)
                }
            });
        }

        //标签图表方法
        function tagChartMethod() {
            $.ajax({
                type: 'POST',
                url: '/getPies',
                success: function (res) {
                    var tagOption = {
                        title: {
                            text: '文章标签统计图',
                            textStyle : {
                                fontWeight: 'normal'
                            },
                            left: 'center'
                        },
                        tooltip: {
                            trigger: 'item'
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                        },
                        series: [
                            {
                                name: '访问来源',
                                type: 'pie',
                                radius: '50%',
                                data: res,
                                emphasis: {
                                    itemStyle: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                    }
                    tagChart.setOption(tagOption)
                }
            })
        }

        //根据窗口的大小变动图表 --- 重点
        window.onresize = function(){
            tagChart.resize();
            typeChart.resize();
        }

        typeChartMethod()
        tagChartMethod()

    </script>

    <script>
        // 显示微信
        $('.wechat').popup({
            popup : $('.wechat-qr'),
            position: 'bottom center'
        })

        // 显示QQ
        $('.QQ').popup({
            popup : $('.qq-qr'),
            position: 'bottom center'
        })

        // 显示邮箱
        $('.email').popup()

        // 显示github
        $('.github').popup()

        $('.ui.accordion').accordion()
    </script>

</body>
</html>
